package cn.edu.scau.cmi.dengzejun.chapter09;

import java.util.*;

public class CalendarBean {
	String[] day;
	int year = 0 , month = 0;
	public void setYear(int year) {
		this.year = year;
		return;
	}
	
	public void setMonth(int month) {
		this.month = month;
		return;
	}
	
	public String[] getCalendar() {
		String[] temp = new String[42];
		Calendar rili = Calendar.getInstance();
		rili.set(year, month-1,1);
		int weekDay = rili.get(Calendar.DAY_OF_WEEK)-1;
		int day = 0;
		switch (month) {
		case 1:
		case 3:
		case 5:
		case 7:
		case 8:
		case 10:
		case 12:
			day = 31;
		case 2:{
			if ((year%4==0)&&(year%100!=0)||(year%400==0)) {
					day = 29;
			}else {
				day = 28;
			} 
		}
		default:
			day = 30;
		}
		for (int i = 0;i<weekDay;++i) {
			temp[i] = " ";
		}
		for (int i = weekDay,n = 1;i<weekDay+day;++i,++n) {
			temp[i] = String.valueOf(n);
		}
		for (int i = weekDay+day;i<temp.length;++i) {
			temp[i] = " ";
		}
		return temp;
	}
}
